<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>24小时-自选池</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">

    <link href="/css/animate.min.css" rel="stylesheet">
    <link href="/css/style.min.css?v=4.0.0" rel="stylesheet"><base target="_blank">
    <!-- Sweet Alert -->
    <link href="/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <!-- 弹窗-->
    <script src="../../tanchuan/js/jquery-2.0.0.min.js"></script>
    <link href="../../tanchuan/css/displaystyle.css" rel="stylesheet" />
    <script src="../../tanchuan/js/syntaxhighlighter_3.0.83/shCore.js"></script>
    <script src="../../tanchuan/js/syntaxhighlighter_3.0.83/shBrushJScript.js"></script>
    <link href="../../tanchuan/js/syntaxhighlighter_3.0.83/styles/shCoreRDark.css" rel="stylesheet" />
    <script src="../../tanchuan/js/NZ-Plugin/Js/NZ-Window.min.js"></script>
    <link href="../../tanchuan/js/NZ-Plugin/Css/NZ-Window.min.css" rel="stylesheet" />
    <script src="../../tanchuan/js/NZ-Plugin/Js/NZ-Drag.min.js"></script>
</head>
<style>
    @keyframes fade {
        from {
            opacity: 1.0;
        }
        50% {
            opacity: 0.0;
        }
        to {
            opacity: 1.0;
        }
    }
    @-webkit-keyframes fade {
        from {
            opacity: 1.00;
        }
        50% {
            opacity: 0;
        }
        to {
            opacity: 1.0;
        }
    }
    .headerBox {
        padding: 1px;
        animation: fade 200ms infinite;
        -webkit-animation: fade 600ms infinite;

    }
</style>
<script>

    function chakanxaingxing(object){
        var code=object.id;
        $.NZ_Window.show({
            url: '/stockMinutes?code='+code,
            width: 1500,
            height: 1000,
            operate: {
                btn_Close: true, //关闭按钮
                btn_Max: true, //最大化按钮
                btn_Refresh: true, //刷新按钮
                btn_NewWindow: true, //新窗口按钮
                resize: true //调整窗口大小按钮
            }
        });
       // window.open('/stockMinutes?code='+code,'','width=2000,height=1000,left=200,top=300,toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=yes');
    }
    function detailInfo(object){
        var code=object.id;
        code=code.replace(/zd_/, "");
        code= code.replace(/sh/, "");
        code= code.replace(/sz/, "");
        var url= 'http://stockpage.10jqka.com.cn/'+code;
        $.NZ_Window.show({
            url: url,
            width: 1100,
            height: 800,
            operate: {
                btn_Close: true, //关闭按钮
                btn_Max: true, //最大化按钮
                btn_Refresh: true, //刷新按钮
                btn_NewWindow: true, //新窗口按钮
                resize: true //调整窗口大小按钮
            }
        });
        // window.open('/stockMinutes?code='+code,'','width=2000,height=1000,left=200,top=300,toolbar=no, status=no, menubar=no, resizable=yes, scrollbars=yes');
    }
</script>
<body class="gray-bg" >
    <div class="wrapper wrapper-content animated fadeInRight">
        <!-- ====================================================== 添加自选 ==========================================================================-->
        <div class="row">
            <div class="col-sm-4">
                <!--    --------------------------------------------- A部分 --------------------------------------------- -->
                <div class="ibox">
                    <div class="ibox-content" >
                        <h3>自选池</h3>
<!--                        <p class="small"><i class="fa fa-hand-o-up"></i> 输入股票代码添加新关注代码</p>-->
                        <div class="input-group">
                            <input type="text" id="codeName" placeholder="添加新股票" class="input input-sm form-control">
                            <span class="input-group-btn">
                                        <button type="button" class="btn btn-sm btn-white" onclick="handleClick()">
                                            <i class="fa fa-plus" onclick="handleClick()"></i> 添加</button>
                                </span>
                        </div>
                        <ul class="sortable-list connectList agile-list" th:each="result,resultStat:${companyStocksList_part_A}">
                            <li class="danger-element" th:id="'warn_'+${result.companyCode}"  >
                                <div>
                                    <a th:id="'name_'+${result.companyCode}" th:text="${result.companyName}" onclick="chakanxaingxing(this)"></a>
                                    <a th:if="${#strings.length(result.companyName) == 3} ">
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    </a>
                                    <a th:if="${#strings.length(result.companyName) == 4} ">
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    </a>
                                    <a th:id="'zd_'+${result.companyCode}"  onclick="detailInfo(this)"></a>
                                    <br/>
                                </div>
                                <div class="agile-detail">
                                    <a class="pull-right btn btn-xs btn-white" th:onclick="'javascript:zhiDingStock('+${result.id}+')' ">置顶</a>
                                    <a class="pull-right btn btn-xs btn-white" th:onclick="'javascript:delStock('+${result.id}+')' ">删除</a>
                                    <i th:text="${result.stockDesc}" style="font-size:13px;"></i>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
            <!--    --------------------------------------------- B 部分 --------------------------------------------- -->
            <div class="col-sm-4">
                <div class="ibox">
                    <div class="ibox-content">
                        <h3>自选池</h3>
<!--                        <p class="small"><i class="fa fa-hand-o-up"></i> 输入股票代码添加新关注代码</p>-->
                        <div class="input-group">
<!--                            <input type="text" id="codeNameB" placeholder="添加新股票" class="input input-sm form-control">-->
<!--                            <span class="input-group-btn">-->
<!--                                        <button type="button" class="btn btn-sm btn-white" onclick="handleClick()">-->
<!--                                            <i class="fa fa-plus" onclick="handleClick()"></i> 添加</button>-->
<!--                                </span>-->
                        </div>
                        <ul class="sortable-list connectList agile-list"
                            th:each="result,resultStat:${companyStocksList_part_B}">
                           <li class="danger-element" th:id="'warn_'+${result.companyCode}" > <!--  onclick="chakanxaingxing(this)"-->
                                <div>
                                    <a th:id="'name_'+${result.companyCode}" th:text="${result.companyName}" onclick="chakanxaingxing(this)"></a>
                                    <a th:if="${#strings.length(result.companyName) == 3} ">
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    </a>
                                    <a th:if="${#strings.length(result.companyName) == 4} ">
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    </a>
                                    <a th:id="'zd_'+${result.companyCode}" onclick="detailInfo(this)"></a>
                                    <br/>
                                </div>
                                <div class="agile-detail">
                                    <a class="pull-right btn btn-xs btn-white" th:onclick="'javascript:zhiDingStock('+${result.id}+')' ">置顶</a>
                                    <a class="pull-right btn btn-xs btn-white" th:onclick="'javascript:delStock('+${result.id}+')' ">删除</a>
                                    <i th:text="${result.stockDesc}" style="font-size:13px;"></i>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
            <!--    --------------------------------------------- C 部分 --------------------------------------------- -->
            <div class="col-sm-4">
                <div class="ibox">
                    <div class="ibox-content">
                        <h3>自选池</h3>
<!--                        <p class="small"><i class="fa fa-hand-o-up"></i> 输入股票代码添加新关注代码</p>-->
                        <div class="input-group">
<!--                            <input type="text" id="codeNameC" placeholder="添加新股票" class="input input-sm form-control">-->
<!--                            <span class="input-group-btn">-->
<!--                                        <button type="button" class="btn btn-sm btn-white" onclick="handleClick()">-->
<!--                                            <i class="fa fa-plus" onclick="handleClick()"></i> 添加</button>-->
<!--                                </span>-->
                        </div>
                        <ul class="sortable-list connectList agile-list"
                            th:each="result,resultStat:${companyStocksList_part_C}">
                            <li class="danger-element" th:id="'warn_'+${result.companyCode}"  >
                                <div>
                                    <a th:id="'name_'+${result.companyCode}" th:text="${result.companyName}" onclick="chakanxaingxing(this)"></a>
                                    <a th:if="${#strings.length(result.companyName) == 3} ">
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    </a>
                                    <a th:if="${#strings.length(result.companyName) == 4} ">
                                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    </a>
                                    <a th:id="'zd_'+${result.companyCode}" onclick="detailInfo(this)"></a>
                                    <br/>
                                </div>
                                <div class="agile-detail">
                                    <a class="pull-right btn btn-xs btn-white" th:onclick="'javascript:zhiDingStock('+${result.id}+')' ">置顶</a>
                                    <a class="pull-right btn btn-xs btn-white" th:onclick="'javascript:delStock('+${result.id}+')' ">删除</a>
                                    <i th:text="${result.stockDesc}" style="font-size:13px;"></i>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        <form id="form1" method="post" action="/addStock">
            <input type="hidden" id="addCode" name="code" value="">
            <input type="hidden" id="addDesc" name="desc" value="">
        </form>
    </div>
<!--    <script src="/js/jquery.min.js?v=2.1.4"></script>-->
    <script src="/js/bootstrap.min.js?v=3.3.5"></script>
    <script src="/js/plugins/sparkline/jquery.sparkline.min.js"></script>
    <script src="/js/plugins/peity/jquery.peity.min.js"></script>
    <script src="/js/content.min.js?v=1.0.0"></script>
    <script src="/js/demo/peity-demo.min.js"></script>
    <script src="/js/plugins/gritter/jquery.gritter.min.js"></script>
    <script src="/js/plugins/sweetalert/sweetalert.min.js"></script>
    <script th:inline="javascript">
        $(document).ready(function () {
            var zhangTingList= [[${zhangTingList}]];
            var dieTingList= [[${dieTingList}]];
            var szList= [[${szList}]];
            var xdList= [[${xdList}]];
            var zhangTingHistory= [[${zhangTingHistory}]];
            var dieTingHistory= [[${dieTingHistory}]];
            var todayQinXuNow= [[${todayQinXuNow}]];

            /**  warn */
            if (todayQinXuNow.yestodayZhangTingWarn >= 90 || todayQinXuNow.yestodayZhangTingWarn <= 50) {
                $('#zhangTingWarn').addClass("headerBox");
            }
            if (todayQinXuNow.ztzs < todayQinXuNow.yestodayMinUpNum) {
                $('#shangZhangWran').addClass("headerBox");
            }

            $("#sparkline1").sparkline( zhangTingList,
                {
                type: "line",
                width: "100%",
                height: "60",
                lineColor: "#ed5565",
                fillColor: "#ffffff"
            });
            $("#sparkline2").sparkline(dieTingList, {
                type: "line",
                width: "100%",
                height: "60",
                lineColor: "#1ab394",
                fillColor: "#ffffff"
            });
            $("#sparkline3").sparkline(szList, {ƒ
                type: "line",
                width: "100%",
                height: "60",
                lineColor: "#ed5565",
                fillColor: "#ffffff"
            });
            $("#sparkline4").sparkline(xdList, {
                type: "line",
                width: "100%",
                height: "60",
                lineColor: "#1ab394",
                fillColor: "#ffffff"
            });
            $("#sparkline10").sparkline( zhangTingHistory,
                {
                    type: "line",
                    width: "100%",
                    height: "60",
                    lineColor: "#ed5565",
                    fillColor: "#ffffff"
                });
            $("#sparkline11").sparkline( dieTingHistory,
                {
                    type: "line",
                    width: "100%",
                    height: "60",
                    lineColor: "#1ab394",
                    fillColor: "#ffffff"
                });
            $("#sparkline5").sparkline([1, 4], {type: "pie", height: "140", sliceColors: ["#1ab394", "#F5F5F5"]});
            $("#sparkline6").sparkline([5, 3], {type: "pie", height: "140", sliceColors: ["#1ab394", "#F5F5F5"]});
            $("#sparkline7").sparkline([2, 2], {type: "pie", height: "140", sliceColors: ["#ed5565", "#F5F5F5"]});
            $("#sparkline8").sparkline([2, 3], {type: "pie", height: "140", sliceColors: ["#ed5565", "#F5F5F5"]})
        });
    </script>
    <script  th:inline="javascript">
        //
        var todayQinXuNow = [[${todayQinXuNow}]];

        function removeWarn(warnCode) {
            //
            $(warnCode).removeClass("headerBox");
            if ('shangZhangWran' == warnCode.id) {
                swal({title: todayQinXuNow.yestodayMaxUpNumWarn, text: ""})
            }
        }
        // //Ajax请求后台数据
        // function myrefresh() {
        //     window.location.reload();
        // }

        //setTimeout('myrefresh()', 60000); //指定1分钟刷新一次
        var companyStocksListPartA = [[${companyStocksList_part_A}]];
        var companyStocksListPartB = [[${companyStocksList_part_B}]];
        var companyStocksListPartC = [[${companyStocksList_part_C}]];

        /**
         * 初始化
         * */
        setTimeout('queryDataTimer(companyStocksListPartA)', 500);
        setTimeout('queryDataTimer(companyStocksListPartB)', 500);
        setTimeout('queryDataTimer(companyStocksListPartC)', 500);

        /**
         * 通過時鐘控制
         * */
        function queryStock()
        {
            queryDataTimer(companyStocksListPartA);
            queryDataTimer(companyStocksListPartB);
            queryDataTimer(companyStocksListPartC);
        }

        function ajaxStock(companyCodes) {
            $.ajax({
                url : '/ajaxRequestGetList',
                type : "post",
                data:{"code":companyCodes},
                success : function(result){
                    $.each(JSON.parse(result), function(idx, data) {
                        // var code1=$.parseJSON(data);
                        var code1=data;
                        var code=code1.code;
                        var zhangdie=code1.zhangdie;
                        var idCode = "#code_" +code;
                        var idZhangDie = "#zd_"+code;
                        var idName = "#name_" + code;
                        var warnCode = "#warn_" + code;
                        if(zhangdie>0){
                            $(idZhangDie).css({"color":"red","font-size":"20px"});
                            $(idName).css({"color":"red","font-size":"20px"});
                            $(idCode).css({"font-size":"10px"});
                        }
                        if(zhangdie < 0){
                            $(idZhangDie).css({"color":"green","font-size":"20px"});
                            $(idName).css({"color":"green","font-size":"20px"});
                            $(idCode).css({"font-size":"10px"});
                            if (zhangdie < -2) {
                                $(warnCode).css({"border": "3px solid red"});
                                $(idZhangDie).addClass("headerBox");
                            }
                        }
                        $(idZhangDie).html(zhangdie+"%");
                    });

                }
            });
        }

        /**
         * 请求信息
         * */
         function queryDataTimer(companyStocksList) {
            var arrayObj = new Array();
            for (var i = 0; i < companyStocksList.length; i++) {
                var companyCode = companyStocksList[i].companyCode;
                if(companyCode != null || companyCode != ""){
                    arrayObj.push(companyCode);
                }
            }
            ajaxStock(arrayObj.toString());
        }
         /**
         * 添加
         * */
        function handleClick() {
            var code = $("#codeName").val();
            if (code == null || code == "" || code.length != 6) {
                if (code.length != 6) {
                    swal({title: "请输入正确的股票代码", text: ""});

                } else {
                    swal({title: "请输入股票代码", text: ""});

                }
            } else {
                if (code.startsWith("6", 0)) {
                    code = "sh" + code;
                } else {
                    code = "sz" + code;
                }
                $.ajax({
                    url: '/ajaxRequest',
                    type: "get",
                    data: {"code": code},
                    success: function (data) {
                        var code1 = $.parseJSON(data);
                        var code = code1.code;
                        var desc = prompt("请输入备注描述：", code1.gpname);
                        $("#addCode").val(code);
                        $("#addDesc").val(desc);
                        handleClickAjax(code, desc);
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        swal({title: "查询失败，请检查股票代码！", text: ""});

                    },
                });
            }
        }

        /**
         * 添加
         * @param code
         * @param desc
         */
        function handleClickAjax(code, desc) {
            $.ajax({
                url: '/addStock',
                type: "get",
                data: {"code": code, "desc": desc},
                success: function (data) {
                    window.location.reload();
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    swal({title: "查询失败，请检查股票代码！", text: ""});
                },
            });
        }

        /**
         * 删除
         * @param code
         * @param desc
         */
        function delStock(stockId) {
            $.ajax({
                url: '/delStock',
                type: "get",
                data: {"id": stockId},
                success: function (data) {
                    swal({title: data, text: ""});
                    window.location.reload();
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    swal({title: "删除失败，请联系管理员！", text: ""});

                },
            });
        }

        /**
         * 置顶关注
         * @param code
         * @param desc
         */
        function zhiDingStock(stockId) {
            $.ajax({
                url: '/zhiDingStock',
                type: "get",
                data: {"id": stockId},
                success: function (data) {
                    swal({title: data, text: ""});
                    window.location.reload();
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    swal({title: "设置失败，请联系管理员！", text: ""});
                },
            });
        }

        function removeCompanyWarn(object)
        {
            var id=object.id;
            swal({title: "跌幅超过2%！", text: ""});
            $(object).removeClass("headerBox");
        }
    </script>
</body>

</html>